package com.ltx.pojo;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Card {
    private int mId;         //会员id
    private Date beginTime;  //办卡日期
    private Date endTime;        //到期日期
    private int balance;     //卡内余额
    private String cardType;     //办卡类型

    public int getmId() {
        return mId;
    }

    public void setmId(int mId) {
        this.mId = mId;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date beginTime,String cardType) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(beginTime);
        if(cardType.equals("周卡")){
            calendar.add(Calendar.DATE, 7);
            this.endTime = calendar.getTime();
        }else if(cardType.equals("月卡")){
            calendar.add(Calendar.DATE, 30);
            this.endTime = calendar.getTime();
        }else if(cardType.equals("季卡")){
            calendar.add(Calendar.DATE, 91);
            this.endTime = calendar.getTime();
        }else if(cardType.equals("年卡")){
            calendar.add(Calendar.DATE, 365);
            this.endTime = calendar.getTime();
        }
    }
    public int getBalance() {
        return balance;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }

    public String getCardType() {
        return cardType;
    }

    public void setCardType(String cardType) {
        this.cardType = cardType;
    }

    @Override
    public String toString() {
        return "Card{" +
                "mId=" + mId +
                ", beginTime=" + beginTime +
                ", endTime=" + endTime +
                ", balance=" + balance +
                ", cardType='" + cardType + '\'' +
                '}';
    }
}
